layui.define([ 'form', 'laydate', 'table','coreDeviceApi'], function(exports) {
    var form = layui.form;
    var coreDeviceApi = layui.coreDeviceApi;
    var index = layui.index;
    var view = {
        init:function(){
            Common.post("/cms/coreCompany/list.json",{"limit":1000},function(data){
                $.each(data,function (i,o){
                    if(o.id==$("#comidval").val())
                        $("#comId").append('<option value="'+o.id+'" selected>'+o.name+'</option>')
                    else
                        $("#comId").append('<option value="'+o.id+'">'+o.name+'</option>')
                })
                form.render('select')
            })
	        Lib.initGenrealForm($("#updateForm"),form);
	        this.initSubmit();
        },
        initSubmit:function(){
            $("#updateButton").click(function(){
                form.on('submit(form)', function(){
                    coreDeviceApi.updateCoreDevice($('#updateForm'),function(){
                       parent.window.dataReload();
                       Common.success("更新成功");
                       Lib.closeFrame();
                    });
                });
            });
            $("#updateButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }
    }
    exports('edit',view);
});